package com.ruoyi.verify.controller;

import java.util.concurrent.atomic.AtomicInteger;

public class ThreadTest {
    public static AtomicInteger count = new AtomicInteger(0);

    public static void main(String[] args) {
        for(int i=0;i<2;i++){
            new Thread(
                    new Runnable() {
                        @Override
                        public void run() {
                            try {
                                Thread.sleep(10);
                            } catch (InterruptedException e) {
                                e.printStackTrace();
                            }
                            for (int j=0;j<100;j++){
//                                synchronized (ThreadTest.class){
//                                    count++;
//                                }
                                count.incrementAndGet();
                            }
                        }
                    }
            ).start();
        }
        try {
            Thread.sleep(20);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("count="+count);
    }
}
